The "A Reference To" Operator
To create a variable whose value is a reference instead of the value of the object specified by a reference, use the A Reference To operator. Here's an example:
set myDoc to a reference to document "Report" ÿ of application "Scriptable Text Editor"The value of the variablemyDoc
is the reference
document "Report" of application "Scriptable Text Editor"After you create a variable whose value is a reference, you can use it in a script anywhere a reference is required. When AppleScript executes the statement containing the variable, it replaces the variable with the reference. For example, when AppleScript executes the statement
tell myDoc get word 1 end tellit replaces the variablemyDoc
with the reference document "Report" of application "Scriptable Text Editor".The syntax for using the A Reference To operator is
[a] ( ref [to] | reference to ) referencewhere reference is a reference to an object. As indicated in the syntax description, there are many ways to shorten expressions containing A Reference To. For example, all of these expressions are equivalent:
set myDoc to a reference to document "Report" of ÿ application "Scriptable Text Editor"set myDoc to reference to document "Report" of ÿ application "Scriptable Text Editor"set myDoc to a ref to document "Report" of application ÿ "Scriptable Text Editor" set myDoc to ref to document "Report" of application ÿ "Scriptable Text Editor"set myDoc to ref document "Report" of application ÿ "Scriptable Text Editor"After you create a reference with the A Reference To operator, you can use the Contents property to get the value of the object that it refers to. The Contents property is the value of the object specified by a reference. For example, the result of the following expression is a string containing the text of document Report of the Scriptable Text Editor.
contents of myDoc